package com.daqian.chance.mybatis.plus.conf;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * 多数据源配置(todo 暂时无用)
 */
//@Configuration
//@EnableTransactionManagement
public class DataSourceConfiguration {

    @Value("${spring.datasource.druid.type}")
    private Class<? extends DataSource> dataSourceType;

    /**
     * 单数据源
     */
    @Bean
    public DataSource dataSource() {
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * 多数据源
     */
//    @Primary
//    @Bean(name = "dataSourceRead")
//    @ConfigurationProperties("spring.datasource.druid.read")
//    public DataSource dataSourceRead() {
//        return DruidDataSourceBuilder.create().build();
//    }
//
//    @Bean(name = "dataSourceWrite")
//    @ConfigurationProperties("spring.datasource.druid.write")
//    public DataSource dataSourceWrite() {
//        return DruidDataSourceBuilder.create().build();
//    }


}